package com.siyuanren.gcocp.input;

import com.siyuanren.gcocp.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.*;

/**
 * Created by   anxing
 * Project_name myCourse
 * Path         com.woodstar.word
 * Date         2018/6/19
 * Time         18:10
 * Description
 */
public class main extends BaseTest {
    @Autowired
    WordParse wordParse;

    @Test
    public void testInitWord() throws Exception {
        File file = new File("D:\\english\\word.txt");
        BufferedReader reader = null;
        String line;

//        System.out.print(Pattern.matches(".*(\\d+).*(\\b\\w*\\b).*", "120、 vert"));
        try {
            reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"gb2312"));
            int index = 0;
            while ((line = reader.readLine()) != null) {
                if(wordParse.parsePartFirt(line)) {
                    continue;
                }
                if (wordParse.parseWord(line)) {
                    continue;
                }
                System.out.println(line + "-------------------------------------------------------------------can't handle");

            }

            // 单词词根与单词关系
            reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"gb2312"));
            while ((line = reader.readLine()) != null) {
                wordParse.parseWordPartRelate(line);
            }
            wordParse.printWordParts();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                reader.close();
            }
        }
    }
}
